package com.netease.nie.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.netease.nie.dao.CreditDao;
import com.netease.nie.dao.CreditHistoryDao;
import com.netease.nie.model.Credit;
import com.netease.nie.model.CreditHistory;

@Service
public class GiftCreditServiceImpl implements GiftCreditService {

	@Autowired
	private CreditDao creditDao;
	
	@Autowired
	private CreditHistoryDao creditHistoryDao;
	
	@Transactional(rollbackFor = Exception.class)
	public int giftUserCredit(Credit credit, CreditHistory creditHistory) throws Exception {
		creditDao.giftUserCredit(credit);
		creditHistoryDao.insertCreditHistory(creditHistory);
		return 1;
	}

}
